Added uuid unit test.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 18 Oct 2005 17:01:14 +0000 (18:01 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 18 Oct 2005 17:01:14 +0000 (18:01 +0100)
Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/tests/test_uuid.py [new file with mode: 0644]

diff --git a/tools/python/xen/xend/tests/test_uuid.py b/tools/python/xen/xend/tests/test_uuid.py
new file mode 100644 (file)
index 0000000..cc78bd0
--- /dev/null
@@ -0,0 +1,30 @@
+import unittest
+
+from xen.xend import uuid
+
+
+class test_uuid(unittest.TestCase):
+
+    def testStringRoundtrip(self):
+        def t(inp):
+            self.assertEqual(uuid.fromString(uuid.toString(inp)), inp)
+
+        t(uuid.create())
+        t(uuid.create())
+        t(uuid.create())
+        t(uuid.create())
+        t(uuid.create())
+
+
+    def testToFromString(self):
+        def t(inp, expected):
+            self.assertEqual(uuid.toString(inp), expected)
+            self.assertEqual(uuid.fromString(expected), inp)
+
+        t([0 for i in range(0, 16)], "00000000-0000-0000-0000-000000000000")
+        t([185, 158, 125, 206, 250, 178, 125, 57, 2, 6, 162, 74, 178, 236,
+           196, 5], "b99e7dce-fab2-7d39-0206-a24ab2ecc405")
+
+
+def test_suite():
+    return unittest.makeSuite(test_uuid)